// pages/city/city.js
const app = getApp()


Page({

  /**
   * 页面的初始数据
   */
  data: {
    //轮播图配置
    autoplay: true,
    interval: 3000,
    duration: 1200,
    carouselMarginTop:0,
    carouselHeight:0,
    indicatorDots:true,
    imgUrls: [
      "/image/prompt.jpg",
      "/image/轮播图 (2).jpg",
      "/image/轮播图 (3).jpg",
      "/image/ttyh_4.jpg",
            ],
    navs:[],
    countNum : '99657133555kg',
    nowNum : '946823kg',
    city:'北京'
  },

    /**
   * 生命周期函数--监听页面加载
   */

  onLoad: function (options) {
    var page = this;
    var navs = this.loadNavData();
    page.setData({navs:navs});
   
  },

  // 获取导航栏的id
  navBtn:function(e){
    console.log(e);
    var id = e.currentTarget.id;
  },

  // 导航菜单栏
  loadNavData: function(){
    var navs=[];
    var nav0=new Object();
    nav0.img='/image/城市 (5).png';
    nav0.name='北京',
    navs[0] = nav0;

    var nav1=new Object();
    nav1.img='/image/城市 (1).png';
    nav1.name='上海',
    navs[1] = nav1;
    
    var nav2=new Object();
    nav2.img='/image/城市 (2).png';
    nav2.name='天津',
    navs[2] = nav2;

    var nav3=new Object();
    nav3.img='/image/城市 (3).png';
    nav3.name='重庆',
    navs[3] = nav3;

    var nav4=new Object();
    nav4.img='/image/城市 (4).png';
    nav4.name='湖北',
    navs[4] = nav4;

    var nav5=new Object();
    nav5.img='/image/城市 (6).png';
    nav5.name='广东',
    navs[5] = nav5;

    var nav6=new Object();
    nav6.img='/image/城市 (7).png';
    nav6.name='深圳',
    navs[6] = nav6;

    var nav7=new Object();
    nav7.img='/image/城市 (8).png';
    nav7.name='福建',
    navs[7] = nav7;
return navs;
  },

  // 动态切换对应城市数据
  numView:function(e){
    var that= this
    var index = e.currentTarget.dataset.index
    if(index == 1){
      that.setData({
        city:'上海',
        countNum: '9826637466kg',
        nowNum: '1257836kg'
      })
    }
    if(index == 2){      
      that.setData({
      city:'天津',
      countNum: '22346737466kg',
      nowNum: '126423166kg'
    })

    }

    if(index == 3){
      that.setData({
        city:'重庆',
        countNum: '85692466kg',
        nowNum: '3684536kg'
      })

    }
    if(index == 4){
      that.setData({
        city:'湖北',
        countNum: '521437464kg',
        nowNum: '16983836kg'
      })

    }
    if(index == 5){
      that.setData({
        city:'广东',
        countNum: '4456637466kg',
        nowNum: '78127836kg'
      })

    }
    if(index == 6){
      that.setData({
        city:'深圳',
        countNum: '7984513236kg',
        nowNum: '125884kg'
      })

    }
    if(index == 7){
      that.setData({
        city:'福建',
        countNum: '7745155256kg',
        nowNum: '698836kg'
      })

    }



  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})